package com.hspedu.tankgame4;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;


/**
 * @author DL5O
 * @version 1.0
 */
public class YwlTankGame04 extends JFrame {
    MyPanel mp = null;
    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        YwlTankGame04 ywlTankGame04 = new YwlTankGame04();
    }

    public YwlTankGame04(){


        System.out.println("请输入选择\n1: 新游戏 \n2: 继续上一局");
        String key = sc.next();
        mp = new MyPanel(key);
        Thread thread_mp = new Thread(mp);
        thread_mp.start();
        this.add(mp);//把面板(就是游戏的绘图区域)塞进去
        this.setSize(1300,950);
        this.addKeyListener(mp);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);

        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                Recorder.keepRecord();
                System.exit(0);
            }
        });
    }

}
